package com.test.mchelepesa.util_rice.data.bean

import android.content.Context
import android.os.Build
import com.google.gson.Gson
import com.test.mchelepesa.util_rice.data.util.GeneralUtil_rice
import com.test.mchelepesa.util_rice.data.util.HardwareUtil_rice
import com.test.mchelepesa.util_rice.data.util.NetworkUtil_rice
import com.test.mchelepesa.util_rice.data.util.StorageUtil_rice

class DeviceInfo_rice(val context: Context, val product: String, val token: String, val path: String) {

    fun fetch(): String? {
        return try {
            val data = hashMapOf<String, Any>().apply {
                put("path", path)
                put("token", token)
                put("product", product)
                put("imei", "")
                put("version", "30")
                put("app", product)
                put("manufacturer", Build.MANUFACTURER ?: "")
                put("brand", Build.BRAND ?: "")
                put("deviceName", Build.DEVICE ?: "")
                put("phoneModel", Build.PRODUCT ?: "")
                put("sysVersion", Build.VERSION.RELEASE ?: "")
                put("mac", NetworkUtil_rice.gMacAddress())
                put("laguage", GeneralUtil_rice.gLanguage())
                put("area", GeneralUtil_rice.gArea())
                put("screenHeight", GeneralUtil_rice.gDeviceHeight(context))
                put("screenWidth", GeneralUtil_rice.gDeviceWidth(context))
                put("networkData", GeneralUtil_rice.gSimOperatorName(context))
                put("frontCameraPixels", HardwareUtil_rice.gFrontCameraPixels(context))
                put("rearCameraPixels", HardwareUtil_rice.gBackCameraPixels(context))
                put("ram", StorageUtil_rice.gRamTotal(context))
                put("rom", StorageUtil_rice.gCashTotal())
                put("ip", NetworkUtil_rice.gIPAddress(context))
                put("ip2", NetworkUtil_rice.gIPAddress(context))
                put("networkEnvironment", GeneralUtil_rice.gNetworkType(context))
                put("cpu", GeneralUtil_rice.gCpuModel())
            }
            Gson().toJson(data).trim()

        } catch (e: Exception) {
            null
        }
    }
}